#pragma once 


#include "rocksdb/slice.h"

namespace helper {
namespace rocksdb {

class SliceUtil {
public:
    template<typename T>
    inline static ::rocksdb::Slice fromNumber(const T & n){
        return ::rocksdb::Slice((const char*)&n, sizeof(T));
    }

    template<typename T>
    inline static const T toNumber(const ::rocksdb::Slice & s){
        //assert(s.data >= sizeof(T));
        return *reinterpret_cast<const T*>(s.data());
    }
};

}//end namespace rocksdb
}//end namespace helper
